#ifndef _SDRAM_DEFINE_H
#define _SDRAM_DEFINE_H

#include <systemc.h>

typedef unsigned	SDRAM_size_t;
typedef unsigned	SDRAM_bitwidth_t;
typedef unsigned	SDRAM_num_t;
typedef unsigned	SDRAM_addr_t;

typedef enum
{
	SDRAM_POWER_ON	= 0,
	SDRAM_IDLE		= 1,
	SDRAM_ROW_ACT	= 2,
	SDRAM_READ		= 3,
	SDRAM_READ_AP	= 4,
	SDRAM_WRITE		= 5,
	SDRAM_WRITE_AP	= 6,
	SDRAM_PRECHARGE	= 7,
	SDRAM_MRS		= 8,
	SDRAM_AUTO_REF	= 9,
	SDRAM_SELF_REF	= 10
} SDRAM_state_t;

typedef enum
{
	IDLE_STATE		= 0,
	READ_STATE		= 1,
	WRITE_STATE		= 2,
	EMRS_STATE		= 3,
	REFRESH_STATE	= 4
} SDRAM_bank_interleave_state_t;

struct SDRAM_bank_state_t
{
	bool			row_active;

	bool			row_activate_enable;
	sc_time			row_activate_enable_time;
	unsigned		row_activate_count;

	unsigned short	row_index;
	unsigned short	col_index;
	unsigned		current_burst;
	unsigned		CAS_latency_count;

	bool			auto_precharge;
	bool			read_precharge_commanded;

	bool			precharge_enable;
	sc_time			precharge_enable_time;
	unsigned		precharge_count;
};

struct SDRAM_bank_control_info_t
{
	SDRAM_state_t	bank_curr_state;
	unsigned		tRCD_cnt;
	unsigned		CL_cnt;
	bool			read_data_enable;
	unsigned		BL_cnt;
	unsigned		read_auto_precharge_cnt;
	unsigned		tRP_cnt;
	SDRAM_addr_t*	bank_addr;
	unsigned		bank_first;
	unsigned		bank_last;
};

#endif
